<?php
class CommonModel extends Model {

	// 获取当前用户的ID
    public function getMemberId() {
        return isset($_SESSION[C('USER_AUTH_KEY')])?$_SESSION[C('USER_AUTH_KEY')]:0;
    }

   /**
     +----------------------------------------------------------
     * 根据条件禁用表数据
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param array $options 条件
     +----------------------------------------------------------
     * @return boolen
     +----------------------------------------------------------
     */
    public function forbid($options,$field='status'){

        if(FALSE === $this->where($options)->setField($field,0)){
            $this->error =  L('_OPERATION_WRONG_');
            return false;
        }else {
            return True;
        }
    }

	 /**
     +----------------------------------------------------------
     * 根据条件批准表数据
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param array $options 条件
     +----------------------------------------------------------
     * @return boolen
     +----------------------------------------------------------
     */

    public function getNaviGroupList($Application_Id=0,$Status=0){
    	$Application_Id=(int)$Application_Id;
    	$Status = (int)$Status;
    	$result= null;
    	if($Application_Id==0&&$Status==0){
    		$result = $this->query("select Id,Name,Status,Application_Id from MIS_NaviGroup");
    	}elseif($Application_Id!=0&&$Status==0){
    		$result =  $this->query("select Id,Name,Status,Application_Id from MIS_NaviGroup where Appliacton_Id=".$Application_Id);
    	}elseif($Application_Id==0&&$Status!=0){
    		$result =  $this->query("select Id,Name,Status,Application_Id from MIS_NaviGroup where Status=$Status");
    	}elseif($Application_Id!=0&&$Status!=0){
    		$result =  $this->query("select Id,Name,Status,Application_Id from MIS_NaviGroup where Appliacton_Id=".$Application_Id." and Status=$Status");
    	}
        if(FALSE == $result){
            $this->error =  L('_OPERATION_WRONG_');
            return false;
        }else {
            return $result;
        }
    }
}
?>